package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSupplierGood;
import com.ruoyi.xh.service.IXhSupplierGoodService;

/**
 * 普通商品Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "普通商品Controller",value = "普通商品Controller")
@RestController
@RequestMapping("/xh/supplierGood")
public class XhSupplierGoodController extends BaseController {

    @Autowired
    private IXhSupplierGoodService xhSupplierGoodService;

    /**
     * 查询普通商品列表
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGood:list')")
    @GetMapping("/list")
    @ApiOperation("查询普通商品列表")
    public TablePageDataInfo<XhSupplierGood> list(XhSupplierGood xhSupplierGood) {
        return TablePageDataInfo.success(xhSupplierGoodService.selectXhSupplierGoodList(xhSupplierGood));
    }

    /**
     * 获取普通商品详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGood:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取普通商品详细信息")
    public CommentResult<XhSupplierGood> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhSupplierGoodService.selectXhSupplierGoodById(id));
    }

    /**
     * 新增普通商品
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGood:add')")
    @Log(title = "普通商品", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增普通商品")
    public CommentResult<XhSupplierGood> add(@RequestBody XhSupplierGood xhSupplierGood) {
            xhSupplierGoodService.insertXhSupplierGood(xhSupplierGood);
        return CommentResult.success();
    }

    /**
     * 修改普通商品
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGood:edit')")
    @Log(title = "普通商品", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改普通商品")
    public CommentResult<XhSupplierGood> edit(@RequestBody XhSupplierGood xhSupplierGood) {
            xhSupplierGoodService.updateXhSupplierGood(xhSupplierGood);
        return CommentResult.success();
    }

    /**
     * 删除普通商品
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierGood:remove')")
    @Log(title = "普通商品", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除普通商品")
    public CommentResult<XhSupplierGood> remove(@PathVariable Long[] ids) {
            xhSupplierGoodService.deleteXhSupplierGoodByIds(ids);
        return CommentResult.success();
    }
}
